package com.dylearn.controller;

import com.dylearn.serve.impl.rabbitmq.RabbitmqDirectImpl;
import com.dylearn.serve.impl.rabbitmq.RabbitmqTopicImpl;
import com.dylearn.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

//@RestController
//@RequestMapping("/rabbitMq")
public class RabbitMqController {
    @Autowired
    RabbitmqDirectImpl rabbitmqDirect;

    @Autowired
    RabbitmqTopicImpl rabbitmqTopic;

    @PostMapping("/{id}")
    public R sendRabbit(@PathVariable String id) throws Exception {

        System.out.println("接收消息！");
        rabbitmqDirect.sendMessage(id);

        return new R(true, "发送消息成功！");
    }

    @PostMapping("/topic/{id}")
    public R sendRabbitTopic(@PathVariable String id) throws Exception {

        System.out.println("接收消息！topic");
        rabbitmqTopic.sendMessage(id);

        return new R(true, "发送消息成功！");
    }
}
